import formBuilder from "@/comps/form/formBuilder";
import api from "./api";
import apiAttr from "../../AttributeKey/js/api"
import apiItemBase from "../../ItemBase/js/api"


export default {
    main:function () {
        let fb = formBuilder()
        fb.setLabelWidth(100)

        fb.addSearch("kId","键名",6)
            .setApi(apiAttr.urlChoice).setApiSearchKeys(["name__like"])

        fb.addSearch("itemBaseId","物料",6)
            .setApi(apiItemBase.urlChoice).setApiSearchKeys(["name__like"])

        fb.addText("name").setSpan(3).setLabel("名称")

        fb.addText("sort").setSpan(3).setLabel("排序").setTypeNumber()

        fb.addText("code").setSpan(3).setLabel("编码")

        fb.addSwitch("isOn","启用",3).setSpan(3)

        fb.addText("note").setSpan(12).setLabel("备注")

        return fb
    },
    tree:function () {
        let fb = formBuilder()
        fb.setLabelWidth(100)

        fb.addCascade("parentId").setLabel("上级分类").setSpan(3)
            .setApi(api.urlTree)

        fb.addText("name").setSpan(6).setLabel("分类名称")
            .setRules([fb.R.notNull("名称不能为空")])

        fb.addText("sort").setSpan(3).setLabel("排序").setTypeNumber()
        return fb
    },
    other:function () {
        let fb = formBuilder()
        fb.setLabelWidth(100).setLabelPosition("right")

        return fb
    }
}